# -*- coding: utf-8 -*-


import unittest
import sys
import os
import time

# 添加执行环境
file_exec_path = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
sys.path.insert(0, file_exec_path)
from framework_strategy.gopy.trader.engine import EmailEngine, MainEngine, EventEngine  # NOQA
from framework_strategy.gopy.base.api import API, Event  # NOQA
from framework_strategy.gopy.gateways.object import *  # NOQA
from framework_strategy.gopy.gateways.xt.xt_api import XTGateway  # NOQA
from framework_strategy.gopy.gateways.binance.binance_api import BINANCEGateway # NOQA
from framework_strategy.gopy.gateways.utils import request # NOQA


class TestRequest(unittest.TestCase):

    @unittest.skip
    def test_request(self):
        from requests import Request, Session
        params = {'market': 'btc_usdt'}
        req = Request('GET', 'https://api.xt.com/data/api/v1/getDepth', params, None)
        prepare = req.prepare()
        print('xxx prepare', prepare)
        print('body', prepare.body)
        res = Session().send(request=prepare)
        print('res', res)

    @unittest.skip
    def test_reuqest_xt(self):
        from requests import Request, Session
        params = {'market': 'btc_usdt'}
        req = Request('GET', 'https://api.xt.com/data/api/v1/getDepth', params, None)
        from framework_strategy.gopy.gateways.ftx.ftx_client import FtxClient
        from framework_strategy.gopy.gateways.settings import FTXAPISETTING
        client = FtxClient(FTXAPISETTING.PUBLIC_KEY, FTXAPISETTING.SECRET_KEY)
        client._request('GET', 'https://api.xt.com/data/api/v1/getDepth', params=params)

    def test_reuqest_ftx(self):
        market = 'BTC/USDT'
        from framework_strategy.gopy.gateways.ftx.ftx_client import FtxClient
        from framework_strategy.gopy.gateways.settings import FTXAPISETTING
        client = FtxClient(FTXAPISETTING.PUBLIC_KEY, FTXAPISETTING.SECRET_KEY)
        # {"params":{'depth': 20}}
        # print(client._request('GET', f'markets/{market}/orderbook', params={'depth': 20}))
        # print(client._get(f'markets/{market}/orderbook', {'depth': 20}))
        print(client._request('GET', f'wallet/balances'))

    @unittest.skip
    def test_kwargs(self):
        def add(**kwargs):
            print(kwargs)
        add(a=1, b=2, c=3)


if __name__ == "__main__":
    unittest.main()
